cmake_minimum_required(VERSION 3.15)
project(webchart_room C)

include(FindPkgConfig)
find_package(libwebsockets REQUIRED)
find_package(json-c REQUIRED)

pkg_search_module(LIBWEBSOCKETS REQUIRED libwebsockets)
pkg_search_module(JSON_C REQUIRED json-c)

set(CMAKE_C_STANDARD 11)

if (${CMAKE_BUILD_TYPE} STREQUAL Debug)
    message("-- Build debug target ...")
    ADD_DEFINITIONS(-DDEBUG)
    set(CMAKE_C_FLAGS, ${CMAKE_C_FLAGS} -O0 -ggdb)
endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)

include_directories(inc)

link_libraries("pthread")
add_executable(webchart_room src/main.c inc/ws_server.h src/ws_server.c inc/common.h inc/http.h src/http.c src/common.c inc/message.h src/message.c inc/room.h src/room.c inc/member.h src/member.c)

target_include_directories(${PROJECT_NAME} PRIVATE ${LIBWEBSOCKETS_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBWEBSOCKETS_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${JSON_C_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${JSON_C_LIBRARIES})

install(TARGETS webchart_room
        RUNTIME DESTINATION usr/bin)